package com.carl.mall.search.controller;


import com.carl.mall.search.service.MallSearchService;
import com.carl.mall.search.vo.SearchParam;
import com.carl.mall.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class SearchController {


    @Autowired
    private MallSearchService mallSearchService;

    @GetMapping(value = {"/list.html","/","/index.html"})
    public String listPage(SearchParam searchParam, Model model){
        //通过对应的service根据传递过来的相关信息取ES中检索对应的数据
        SearchResult search = mallSearchService.search(searchParam);
        model.addAttribute("result",search);
        return "index";
    }

//    @GetMapping("/search.html")
//    public String searchPage(String keyword){
//        return "index";
//    }
}
